/*
 *
 * Copyright 2017-2018. All rights reserved.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, see <http://www.gnu.org/licenses/>.
 *
 */
package com.loveprogrammer.eternity.enums;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

/**
 * 技能品质
 *
 * @author eric
 * @version 1.0.0
 */
public enum SkillQualityEnum {

    E("E", 1d),
    D("D", 1.25d),
    C("C", 1.6d),
    B("B", 2.0d),
    A("A", 2.57d),
    S("S", 3.1d),
    SS("SS", 3.6d),
    SSS("SSS", 4.1d);

    private String code;

    private Double ratio;

    SkillQualityEnum(String code, Double ratio) {
        this.code = code;
        this.ratio = ratio;
    }

    public static SkillQualityEnum getByCode(String code){
        Optional<SkillQualityEnum> optional =
                Arrays.stream(SkillQualityEnum.values())
                        .filter(v -> Objects.equals(v.getCode(), code))
                        .findFirst();

        return optional.orElse(SkillQualityEnum.E);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Double getRatio() {
        return ratio;
    }

}
